<!DOCTYPE html>
<html>

<head>
    <include file="public@head" title="栏目编辑"/>
</head>

<body class="layui-layout-admin">
<include file="public@header"/>
<include file="public@side"/>
<div class="layui-body">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a href="{:url('admin/index/index')}">主页</a>
        <a>内容管理</a>
        <a href="{:url('index')}">栏目管理</a>
        <a><cite>编辑栏目</cite></a>
    </div>
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-header">
                编辑栏目
            </div>
            <div class="layui-card-body layui-row">
                <form method="post" class="layui-form layui-col-md6" action="{:url('edit')}">
                    <div class="layui-form-item">
                        <label class="layui-form-label">栏目名称<span class="form-required">*</span></label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" value="{$name}" name="name" lay-verify="required"
                                   lay-verType="tips">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">上级栏目<span class="form-required">*</span></label>
                        <div class="layui-input-inline">
                            <select name="parent_id" lay-verify="required">
                                <option value="0">一级栏目</option>
                                <foreach name="categories" item="vo">
                                    <option value="{$vo.id}" <eq name="parent_id" value="$vo['id']">selected</eq> >{$vo.tab}{$vo.name}</option>
                                </foreach>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">内容类型<span class="form-required">*</span></label>
                        <div class="layui-input-block">
                            <input type="radio" name="type" value="1" title="默认类型" <eq name="type" value="1">checked</eq> >
                            <input type="radio" name="type" value="2" title="图文" <eq name="type" value="2">checked</eq> >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">SEO标题</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="seo_title" value="{$seo_title}"
                                   placeholder="请输入SEO标题">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">SEO关键词</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="keywords" value="{$keywords}"
                                   placeholder="请输入SEO关键词">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">SEO描述</label>
                        <div class="layui-input-block">
                            <textarea class="layui-textarea" name="description"
                                      placeholder="您可以输入SEO描述">{$description}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="hidden" name="id" value="{$id}"/>
                            <button type="submit" class="layui-btn" lay-submit lay-filter="general">提交</button>
                            <a class="layui-btn layui-btn-primary" href="javascript:history.back(-1);">返回</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<include file="public@scripts"/>
<script>
    $('#name').blur(function () {
        var name = $(this).val();
        $.post("{:url('category/checkName')}", {'name': name}, function (res) {
            if (res.code == 1) {
                layer.msg(res.msg, {icon: 1}, function () {
                    return false;
                });
            } else {
                layer.msg(res.msg, {icon: 2}, function () {
                    return false;
                });
            }
        });
    });
</script>
</body>

</html>
